package com.jh3502.vivo.function.tododetail.reim;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jh3502.vivo.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * author:harisucici on 2018/11/14 11:33
 * email:harisucici@gmail.com
 * name:
 * todo:
 */
public class TodoReimAuditsAdapter extends RecyclerView.Adapter<TodoReimAuditsAdapter.ViewHolder> {

    Context mContext;
    private View convertView;
    private List<TodoReimAuditsBean> dataList;

    public TodoReimAuditsAdapter(Context context, List<TodoReimAuditsBean> dataList) {
        this.mContext = context;
        this.dataList = dataList;
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
        convertView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_reim_audits, viewGroup, false);
        ViewHolder vh = new ViewHolder(convertView);
        return vh;
    }

    @Override
    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
        viewHolder.itemView.setTag(position);
        TodoReimAuditsBean bean = dataList.get(position);
        if (bean.getAudit() == null) {
            Glide.with(mContext).load(R.drawable.plus_contact).into(viewHolder.itemReimPoint);
            viewHolder.itemReimCont.setText("");
            viewHolder.itemReimDate.setText("");
            viewHolder.itemReimIcon.setVisibility(View.INVISIBLE);

        } else {
            Glide.with(mContext).load(R.drawable.btn_check_selected).into(viewHolder.itemReimPoint);
            viewHolder.itemReimCont.setText(bean.getAudit().getName());
            viewHolder.itemReimDate.setText(bean.getAudit().getDate());
            viewHolder.itemReimIcon.setVisibility(View.VISIBLE);

        }
        viewHolder.itemReimTitle.setText(bean.getNodeName());


    }


    @Override
    public int getItemCount() {

        return dataList.size();
    }


    public interface ButtonInterface {
        void onClick(int position);
    }


    public interface OnRecyclerViewItemClickListener {
        void onItemClick(int i);
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_reim_point)
        ImageView itemReimPoint;
        @BindView(R.id.item_reim_title)
        TextView itemReimTitle;
        @BindView(R.id.item_reim_cont)
        TextView itemReimCont;
        @BindView(R.id.item_reim_date)
        TextView itemReimDate;
        @BindView(R.id.item_reim_icon)
        ImageView itemReimIcon;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);

        }
    }

}
